#include "pageselftest.h"
#include "ui_pageselftest.h"

PageSelfTest::PageSelfTest(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::PageSelfTest)
{
    ui->setupUi(this);
    setAutoFillBackground(true);  //设置自动填充
    QPalette palette = BKGCLR;
    setPalette(palette);

    m_lSysSelfTestLabels.append(ui->hvs);
    m_lSysSelfTestLabels.append(ui->pro);
    m_lSysSelfTestLabels.append(ui->dis);
    m_lSysSelfTestLabels.append(ui->drv);
    m_lSysSelfTestLabels.append(ui->brk);
    m_lSysSelfTestLabels.append(ui->tms);
    m_lSysSelfTestLabels.append(ui->lcu);
    m_lSysSelfTestLabels.append(ui->dor);
    m_lSysSelfTestLabels.append(ui->pis);
    m_lSysSelfTestLabels.append(ui->hvac);
    m_lSysSelfTestLabels.append(ui->lgt);
    m_lSysSelfTestLabels.append(ui->fas);
    m_lSysSelfTestLabels.append(ui->dds);
    m_lSysSelfTestLabels.append(ui->radio);
    m_lSysSelfTestLabels.append(ui->gpis);
    m_lSysSelfTestLabels.append(ui->bds);
    m_lSysSelfTestLabels.append(ui->bms);
    m_lSysSelfTestLabels.append(ui->ods);
    m_lSysSelfTestLabels.append(ui->panms);
    m_lSysSelfTestLabels.append(ui->icds);
    m_lSysSelfTestLabels.append(ui->tcds);
    m_lSysSelfTestLabels.append(ui->ecr);

    m_lSysStaticSelfTestLabels.append(ui->static_test1_1);m_lSysStaticSelfFail.append(false);m_lSysStaticSelfSuccess.append(false);
    m_lSysStaticSelfTestLabels.append(ui->static_test2_1);m_lSysStaticSelfFail.append(false);m_lSysStaticSelfSuccess.append(false);
    m_lSysStaticSelfTestLabels.append(ui->static_test3_1);m_lSysStaticSelfFail.append(false);m_lSysStaticSelfSuccess.append(false);
    m_lSysStaticSelfTestLabels.append(ui->static_test4_1);m_lSysStaticSelfFail.append(false);m_lSysStaticSelfSuccess.append(false);
    m_lSysStaticSelfTestLabels.append(ui->static_test5_1);m_lSysStaticSelfFail.append(false);m_lSysStaticSelfSuccess.append(false);
    m_lSysStaticSelfTestLabels.append(ui->static_test6_1);m_lSysStaticSelfFail.append(false);m_lSysStaticSelfSuccess.append(false);
    m_lSysStaticSelfTestLabels.append(ui->static_test7_1);m_lSysStaticSelfFail.append(false);m_lSysStaticSelfSuccess.append(false);
    m_lSysStaticSelfTestLabels.append(ui->static_test8_1);m_lSysStaticSelfFail.append(false);m_lSysStaticSelfSuccess.append(false);
    m_lSysStaticSelfTestLabels.append(ui->static_test9_1);m_lSysStaticSelfFail.append(false);m_lSysStaticSelfSuccess.append(false);
    m_lSysStaticSelfTestLabels.append(ui->static_test10_1);m_lSysStaticSelfFail.append(false);m_lSysStaticSelfSuccess.append(false);
    m_lSysStaticSelfTestLabels.append(ui->static_test11_1);m_lSysStaticSelfFail.append(false);m_lSysStaticSelfSuccess.append(false);
    m_lSysStaticSelfTestLabels.append(ui->static_test12_1);m_lSysStaticSelfFail.append(false);m_lSysStaticSelfSuccess.append(false);
    m_lSysStaticSelfTestLabels.append(ui->static_test13_1);m_lSysStaticSelfFail.append(false);m_lSysStaticSelfSuccess.append(false);
    m_lSysStaticSelfTestLabels.append(ui->static_test14_1);m_lSysStaticSelfFail.append(false);m_lSysStaticSelfSuccess.append(false);
    m_lSysStaticSelfTestLabels.append(ui->static_test15_1);m_lSysStaticSelfFail.append(false);m_lSysStaticSelfSuccess.append(false);
    m_lSysStaticSelfTestLabels.append(ui->static_test16_1);m_lSysStaticSelfFail.append(false);m_lSysStaticSelfSuccess.append(false);
    m_lSysStaticSelfTestLabels.append(ui->static_test17_1);m_lSysStaticSelfFail.append(false);m_lSysStaticSelfSuccess.append(false);
    m_lSysStaticSelfTestLabels.append(ui->static_test18_1);m_lSysStaticSelfFail.append(false);m_lSysStaticSelfSuccess.append(false);
    m_lSysStaticSelfTestLabels.append(ui->static_test19_1);m_lSysStaticSelfFail.append(false);m_lSysStaticSelfSuccess.append(false);
    m_lSysStaticSelfTestLabels.append(ui->static_test20_1);m_lSysStaticSelfFail.append(false);m_lSysStaticSelfSuccess.append(false);
    m_lSysStaticSelfTestLabels.append(ui->static_test21_1);m_lSysStaticSelfFail.append(false);m_lSysStaticSelfSuccess.append(false);
    m_lSysStaticSelfTestLabels.append(ui->static_test22_1);m_lSysStaticSelfFail.append(false);m_lSysStaticSelfSuccess.append(false);
    m_lSysStaticSelfTestLabels.append(ui->static_test1_2);m_lSysStaticSelfFail.append(false);m_lSysStaticSelfSuccess.append(false);
    m_lSysStaticSelfTestLabels.append(ui->static_test2_2);m_lSysStaticSelfFail.append(false);m_lSysStaticSelfSuccess.append(false);
    m_lSysStaticSelfTestLabels.append(ui->static_test3_2);m_lSysStaticSelfFail.append(false);m_lSysStaticSelfSuccess.append(false);
    m_lSysStaticSelfTestLabels.append(ui->static_test4_2);m_lSysStaticSelfFail.append(false);m_lSysStaticSelfSuccess.append(false);
    m_lSysStaticSelfTestLabels.append(ui->static_test5_2);m_lSysStaticSelfFail.append(false);m_lSysStaticSelfSuccess.append(false);
    m_lSysStaticSelfTestLabels.append(ui->static_test6_2);m_lSysStaticSelfFail.append(false);m_lSysStaticSelfSuccess.append(false);
    m_lSysStaticSelfTestLabels.append(ui->static_test7_2);m_lSysStaticSelfFail.append(false);m_lSysStaticSelfSuccess.append(false);
    m_lSysStaticSelfTestLabels.append(ui->static_test8_2);m_lSysStaticSelfFail.append(false);m_lSysStaticSelfSuccess.append(false);
    m_lSysStaticSelfTestLabels.append(ui->static_test9_2);m_lSysStaticSelfFail.append(false);m_lSysStaticSelfSuccess.append(false);
    m_lSysStaticSelfTestLabels.append(ui->static_test10_2);m_lSysStaticSelfFail.append(false);m_lSysStaticSelfSuccess.append(false);
    m_lSysStaticSelfTestLabels.append(ui->static_test11_2);m_lSysStaticSelfFail.append(false);m_lSysStaticSelfSuccess.append(false);
    m_lSysStaticSelfTestLabels.append(ui->static_test12_2);m_lSysStaticSelfFail.append(false);m_lSysStaticSelfSuccess.append(false);
    m_lSysStaticSelfTestLabels.append(ui->static_test13_2);m_lSysStaticSelfFail.append(false);m_lSysStaticSelfSuccess.append(false);
    m_lSysStaticSelfTestLabels.append(ui->static_test14_2);m_lSysStaticSelfFail.append(false);m_lSysStaticSelfSuccess.append(false);
    m_lSysStaticSelfTestLabels.append(ui->static_test15_2);m_lSysStaticSelfFail.append(false);m_lSysStaticSelfSuccess.append(false);
    m_lSysStaticSelfTestLabels.append(ui->static_test16_2);m_lSysStaticSelfFail.append(false);m_lSysStaticSelfSuccess.append(false);
    m_lSysStaticSelfTestLabels.append(ui->static_test17_2);m_lSysStaticSelfFail.append(false);m_lSysStaticSelfSuccess.append(false);
    m_lSysStaticSelfTestLabels.append(ui->static_test18_2);m_lSysStaticSelfFail.append(false);m_lSysStaticSelfSuccess.append(false);
    m_lSysStaticSelfTestLabels.append(ui->static_test19_2);m_lSysStaticSelfFail.append(false);m_lSysStaticSelfSuccess.append(false);
    m_lSysStaticSelfTestLabels.append(ui->static_test20_2);m_lSysStaticSelfFail.append(false);m_lSysStaticSelfSuccess.append(false);
    m_lSysStaticSelfTestLabels.append(ui->static_test21_2);m_lSysStaticSelfFail.append(false);m_lSysStaticSelfSuccess.append(false);
    m_lSysStaticSelfTestLabels.append(ui->static_test22_2);m_lSysStaticSelfFail.append(false);m_lSysStaticSelfSuccess.append(false);
}

PageSelfTest::~PageSelfTest()
{
    delete ui;
}

void PageSelfTest::on_Btn_Return_clicked()
{
    emit signal_go_back();
}

void PageSelfTest::setOPSelfTestStat(int sys,bool xfailed)
{
    if(sys >= m_lSysSelfTestLabels.length() || sys < 0)
        return;
    if(xfailed)
        m_lSysSelfTestLabels[sys]->setStyleSheet("background-color: rgb(255,0,0);font:15pt 'arial';");
    else
        m_lSysSelfTestLabels[sys]->setStyleSheet("background-color: rgb(0,255,0);font:15pt 'arial';");
}

void PageSelfTest::setOPStaticSelfTestFailStat(int index, bool xfailed)
{
    if(index >= m_lSysStaticSelfFail.length() || index < 0)
        return;
    m_lSysStaticSelfFail[index] = xfailed;
    updateSysStaticSelfTestStat(index);
}

void PageSelfTest::setOPStaticSelfTestSuccessStat(int index,bool xSuccess)
{
    if(index >= m_lSysStaticSelfSuccess.length() || index < 0)
        return;
    m_lSysStaticSelfSuccess[index] = xSuccess;
    updateSysStaticSelfTestStat(index);
}

void PageSelfTest::updateSysStaticSelfTestStat(int index)
{
    if(m_lSysStaticSelfFail.at(index))
        m_lSysStaticSelfTestLabels[index]->setStyleSheet("background-color: rgb(255,0,0);font:13pt 'arial';");
    else if(m_lSysStaticSelfSuccess.at(index))
        m_lSysStaticSelfTestLabels[index]->setStyleSheet("background-color: rgb(0,255,0);font:13pt 'arial';");
    else
        m_lSysStaticSelfTestLabels[index]->setStyleSheet("background-color: rgb(197,197,197);font:13pt 'arial';");
}

void PageSelfTest::setTCDSVisible(bool xVisible)
{
   ui->tcds->setVisible(xVisible);
}
